﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using nTribeHR;
using nTribeHR.Utilities;

namespace nTribeHRTests
{
    [TestClass]
    public class UserRequestServiceTests : BaseTribeHRUnitTest
    {

        protected TribeHRUserRequestService Service { get; set; }
        
        [TestInitialize]
        public override void Initialize()
        {
            base.Initialize();
            Service = new TribeHRUserRequestService(TribeHRConnection);
        }

        [TestMethod]
        public void CanGetListOfTribeHRUsers()
        {

            var result = Service.GetUsers();
            Console.WriteLine(Service.WebRequestStopwatch.ToString());
            Console.WriteLine(Service.LoadXmlStopwatch.ToString());
            Console.WriteLine(Service.ParseResultStopwatch.ToString());


            Assert.IsNotNull(result);
        }

        [TestMethod]
        public void CanGetMyPersonalTribeHRUserDetails()
        {

            var userList = Service.GetUsers();
            Console.WriteLine(Service.WebRequestStopwatch.ToString());
            Console.WriteLine(Service.LoadXmlStopwatch.ToString());
            Console.WriteLine(Service.ParseResultStopwatch.ToString());

            Assert.IsNotNull(userList);

            string userEmail = string.Empty;

            var me = userList.SingleOrDefault(u => u.Email == userEmail);

            Assert.IsNotNull(me);

            var user = Service.GetUserById(me.Id);


        }

    }
}
